<template>
	<view>
		<view class="boutique">
			<view class="boutique-title">
				<view class="top-title">
					<view class="top-tips">
						免费课程
					</view>
					<view @click="more">
						更多>
					</view>
				</view>
				<view class="boutique-content">
					<view class="small-content" v-for="(item,index) in freeClassData" :key="index" @click="goDetail(item.courseId)">
						<image :src="item.bannerFileUrl" class="class-img"></image>
						<view class="bottom-title">
							{{item.courseTitle}}
						</view>
						<view class="bottom-tip">
							<view class="free-word">
								免费
							</view>
							<view class="small-live">
								<image src="../static/images/live.png" mode="widthFix"></image>
								{{item.learningNum}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getPost} from "../api/index.js"
	export default {
		name:"free",
		data() {
			return {
				freeClassData:[]
			};
		},
		methods:{
			goDetail(data){
				console.log(data)
				uni.navigateTo({
					url:`/pages/detail/detail?id=${data}`
				})
			},
			more(){
				uni.navigateTo({
					url:`/pages/more/more?id=2`
				})
			}
		},
		created() {
			getPost("/weChat/applet/course/list/type",{
				type:"free",pageNum:1,pageSize:6
			}).then(res=>{
				// console.log(res.data.rows)
				this.freeClassData=res.data.rows
			})
		}
	}
</script>

<style lang="less" scoped>
	.small-content{
		display: flex;
	}
	.boutique-content{
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.small-live{
		image{
			width: 20rpx;
			margin-right: 10rpx;
		}
	}
	.class-img{
		width: 340rpx;
		height: 170rpx;
	}
	.bottom-title{
		height: 34px;
	}
	.small-content{
		padding: 10rpx 0;
		width: 340rpx;
		display: flex;
		flex-direction: column;
	}
	.bottom-tip{
		margin-top: 15rpx;
		display: flex;
		justify-content: space-between;
	}
	.free-word{
		color: #00cf8c;
	}
	.top-tips{
		font-size: 30rpx;
		font-weight: bold;
	}
	.top-title{
		padding: 20rpx 0;
		display: flex;
		justify-content: space-between;
	}
</style>
